package pkg

import (
	"math/rand"
	"shop/database/redis"
	"strconv"
	"time"
)

func SendCode(phone string) (int, error) {
	// 生成 1000 到 9999 之间的随机整数
	intn := rand.Intn(8999 + 1000)
	err := redis.SetString(phone, strconv.Itoa(intn), time.Minute*1)
	if err != nil {
		return 0, err
	}
	return intn, err
}
